package com.dynamicthreadpool.netty.protocol;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * 线程池控制消息协议
 */
public class ThreadPoolControlMessage implements Serializable {
    private static final long serialVersionUID = 1L;
    
    // 操作类型：create, update, shutdown, status
    private String operation;
    
    // 线程池标识
    private String poolId;
    
    // 访问令牌，用于身份验证
    private String accessToken;
    
    // 线程池参数，对应URL中的参数
    private Map<String, String> parameters = new HashMap<>();
    
    // 响应状态：success, error
    private String status;
    
    // 响应消息
    private String message;
    
    // 线程池状态信息（用于status操作）
    private Map<String, Object> poolStatus = new HashMap<>();
    
    // 构造方法、getter和setter
    public ThreadPoolControlMessage() {}
    
    public ThreadPoolControlMessage(String operation, String poolId) {
        this.operation = operation;
        this.poolId = poolId;
    }
    
    public String getOperation() {
        return operation;
    }
    
    public void setOperation(String operation) {
        this.operation = operation;
    }
    
    public String getPoolId() {
        return poolId;
    }
    
    public void setPoolId(String poolId) {
        this.poolId = poolId;
    }
    
    public String getAccessToken() {
        return accessToken;
    }
    
    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }
    
    public Map<String, String> getParameters() {
        return parameters;
    }
    
    public void setParameters(Map<String, String> parameters) {
        this.parameters = parameters;
    }
    
    public String getStatus() {
        return status;
    }
    
    public void setStatus(String status) {
        this.status = status;
    }
    
    public String getMessage() {
        return message;
    }
    
    public void setMessage(String message) {
        this.message = message;
    }
    
    public Map<String, Object> getPoolStatus() {
        return poolStatus;
    }
    
    public void setPoolStatus(Map<String, Object> poolStatus) {
        this.poolStatus = poolStatus;
    }
    
    @Override
    public String toString() {
        return "ThreadPoolControlMessage{" +
                "operation=\"" + operation + "\"" +
                ", poolId=\"" + poolId + "\"" +
                ", accessToken=\"" + (accessToken != null ? "***" : null) + "\"" +
                ", parameters=" + parameters +
                ", status=\"" + status + "\"" +
                ", message=\"" + message + "\"" +
                "}";
    }
}